<?php

global $_W, $_GPC;
$uniacid = $_W['uniacid'];

load()->func('tpl');
$opp = 'wxacode';
$poster = pdo_fetch("select * from " . tablename('bbyscm_card_wxacode') . ' where `uniacid`=:uniacid limit 1', array(':uniacid' => $uniacid));
if(!empty($poster)) {
    $data = json_decode(str_replace('&quot;', "'", $poster['data']), true);
}
if (checksubmit('submit')) {
    $data3 = array(
        'uniacid' => $_W['uniacid'],
        'bg' => tomedia($_GPC['bg']),
        'data' => htmlspecialchars_decode($_GPC['data']),
        'createtime' => time()
    );
    if (!empty($poster)) {
        pdo_update('bbyscm_card_wxacode', $data3, array('id' => $poster['id'], 'uniacid' => $_W['uniacid']));
    } else {
        pdo_insert('bbyscm_card_wxacode', $data3);
        $id = pdo_insertid();
    }
    message('更新参数设置成功！', 'refresh');
}

include $this->template('web/wxacode');